# -*- coding: utf-8 -*-
#
# Author:: Jonny
# Date:: 2022/6/15


# 清理进程
import os
import random
from time import sleep

from PIL import Image

from compat import project_paths
from compat.project_paths import project_path
from config import constants
from lib.adb_ import (
    click_by_image,
    is_exsit,
    swipe,
    click_by_bounds,
    init_screenshot_path,
    get_screenshot,
)
from lib.decorators import count_exec_time
from submodules.common.lib import json_
from submodules.common.lib.adb_ import get_adb_devices_ready, kill, start
from submodules.common.lib.datetime_ import get_timestamp, get_timestamp_unix
from submodules.common.lib.log_ import get_logger

logger = get_logger()
obj_path = os.path.join(project_path, "obj")

# 判断今日日常是否已完成
# 是 exit
# 否继续

# 清理
from obj import obj_info


@count_exec_time
def 获取当前账号(timeout=60 * 15):
    timestamp_start = get_timestamp_unix()

    for i in range(3):
        kill(constants.PACKAGE_NAME_WENDAO)
        sleep(3)
        os.popen("/opt/xdroid/command-xapp-center.sh --start-app com.gbits.atm.leiting")
        # start(constants.PACKAGE_NAME_WENDAO, constants.ACTIVITY_NAME_WENDAO_MAIN)
        sleep(15)
        if is_exsit(obj_info.登录页面__默认__左侧账户图标, threshold=0.99) or is_exsit(
            obj_info.登录页面__登录弹窗__左侧账户图标, threshold=0.99
        ):
            break
        else:
            cmd_str = (
                "/home/Jonny/code/wendao/scripts/linux/linzhuo/modify_resolution720p.sh"
            )
            os.popen(cmd_str)
            sleep(10)
            get_adb_devices_ready()

    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        init_screenshot_path()
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        """
        最近一次登录设备有变更，需确认缺色
        最近一次登录设备无变更，直接进入游戏
        """

        click_by_image(obj_info.登录页面__更新弹窗__继续游戏按钮)
        click_by_image(obj_info.登录页面__储存权限弹窗__允许按钮)
        click_by_image(obj_info.登录页面__储存权限弹窗2__允许按钮)

        click_by_image(obj_info.登录页面__更新确认弹窗__确认按钮)
        click_by_image(obj_info.登录页面__更新完成确认弹窗__确认按钮)
        click_by_image(obj_info.登录页面__更新公告弹窗__关闭按钮)

        click_by_image(obj_info.主页面__托管弹窗__关闭按钮)

        click_by_image(obj_info.登录页面__默认__左侧账户图标)
        click_by_image(obj_info.登录页面__登录弹窗__切换账号图标)
        click_by_image(obj_info.登录页面__登录弹窗2__使用雷霆账号登录文案)
        click_by_image(obj_info.登录页面__登录弹窗22__使用雷霆账号登录文案)
        click_by_image(obj_info.登录页面__登录弹窗222__使用雷霆账号登录文案)
        click_by_image(obj_info.登录页面__登录弹窗5__使用雷霆账号登录文案)
        click_by_image(obj_info.登录页面__登录弹窗3__账号文本框_下拉图标)

        # 手机号外形相似难以分辨，考虑使用OCR
        # res = None
        # if is_exsit(obj_info.登录页面__登录弹窗_水系账号__账号文本框_下拉菜单第一项):
        #     res = "水系账号"
        #     logger.info(f"账号类型:{res}")
        # if is_exsit(obj_info.登录页面__登录弹窗_木系账号__账号文本框_下拉菜单第一项):
        #     res = "木系账号"
        #     logger.info(f"账号类型:{res}")
        # if is_exsit(obj_info.登录页面__登录弹窗_火系账号__账号文本框_下拉菜单第一项):
        #     res = "火系账号"
        #     logger.info(f"账号类型:{res}")
        # if is_exsit(obj_info.登录页面__登录弹窗_男火账号__账号文本框_下拉菜单第一项):
        #     res = "男火账号"
        #     logger.info(f"账号类型:{res}")

        click_by_image(
            obj_info.登录页面__登录弹窗4__账号文本框_下拉菜单第一项,
            obj_info.登录页面__登录弹窗4__账号文本框_下拉菜单第一项_删除图标,
        )
        click_by_image(obj_info.登录页面__登录弹窗3__账号文本框_用户协议_复选框)
        res2 = click_by_image(obj_info.登录页面__登录弹窗3__雷霆账号登录按钮)
        if res2:
            sleep(5)
        click_by_image(obj_info.主页面__托管弹窗__托管预览按钮)
        click_by_image(obj_info.主页面__托管弹窗__进入游戏按钮)
        click_by_image(obj_info.登录页面__默认__进入游戏按钮)
        sleep(3)

        # if res is not None:
        #     return res

        # 游戏内识别
        res = click_by_image(obj_info.主页面__默认__人物头像区域, obj_info.主页面__默认__刷道按钮)
        if res:
            sleep(0.5)
            if is_exsit(obj_info.主页面__人物信息弹窗_水系账号__编号区域):
                res = "水系账号"
                logger.info(f"当前账号类型:{res}")
                click_by_image(obj_info.主页面__人物信息弹窗__关闭按钮)
                return res
            if is_exsit(obj_info.主页面__人物信息弹窗_木系账号__编号区域):
                res = "木系账号"
                logger.info(f"当前账号类型:{res}")
                click_by_image(obj_info.主页面__人物信息弹窗__关闭按钮)
                return res
            if is_exsit(obj_info.主页面__人物信息弹窗_火系账号__编号区域):
                res = "火系账号"
                logger.info(f"当前账号类型:{res}")
                click_by_image(obj_info.主页面__人物信息弹窗__关闭按钮)
                return res


@count_exec_time
def 切换账号(timeout=60 * 15):
    timestamp_start = get_timestamp_unix()

    for i in range(3):
        kill(constants.PACKAGE_NAME_WENDAO)
        sleep(3)
        # start(constants.PACKAGE_NAME_WENDAO, constants.ACTIVITY_NAME_WENDAO_MAIN)
        # os.popen("/opt/xdroid/command-xapp-center.sh --start-app com.gbits.atm.leiting")
        os.popen(
            "$(awk -F= '/^Exec/||/^TryExec/ {print $2;exit}' /home/Jonny/Desktop/问道.desktop)"
        )
        sleep(15)
        if is_exsit(obj_info.登录页面__默认__左侧账户图标, threshold=0.99) or is_exsit(
            obj_info.登录页面__登录弹窗__左侧账户图标, threshold=0.99
        ):
            break
        else:
            cmd_str = (
                "/home/Jonny/code/wendao/scripts/linux/linzhuo/modify_resolution720p.sh"
            )
            os.popen(cmd_str)
            sleep(10)
            get_adb_devices_ready()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        init_screenshot_path()
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.登录页面__更新弹窗__继续游戏按钮)
        click_by_image(obj_info.登录页面__储存权限弹窗__允许按钮)
        click_by_image(obj_info.登录页面__储存权限弹窗2__允许按钮)

        click_by_image(obj_info.登录页面__更新确认弹窗__确认按钮)
        click_by_image(obj_info.登录页面__更新完成确认弹窗__确认按钮)
        click_by_image(obj_info.登录页面__更新公告弹窗__关闭按钮)

        click_by_image(obj_info.主页面__托管弹窗__关闭按钮)

        click_by_image(obj_info.登录页面__默认__左侧账户图标)
        click_by_image(obj_info.登录页面__登录弹窗__切换账号图标)
        click_by_image(obj_info.登录页面__登录弹窗2__使用雷霆账号登录文案)
        click_by_image(obj_info.登录页面__登录弹窗22__使用雷霆账号登录文案)
        click_by_image(obj_info.登录页面__登录弹窗222__使用雷霆账号登录文案)
        click_by_image(obj_info.登录页面__登录弹窗5__使用雷霆账号登录文案)
        click_by_image(obj_info.登录页面__登录弹窗3__账号文本框_下拉图标)
        sleep(0.5)
        click_by_image(
            obj_info.登录页面__登录弹窗4__账号文本框_下拉菜单第一项,
            obj_info.登录页面__登录弹窗4__账号文本框_下拉菜单第一项_删除图标,
        )
        click_by_image(obj_info.登录页面__登录弹窗3__账号文本框_用户协议_复选框)
        res2 = click_by_image(obj_info.登录页面__登录弹窗3__雷霆账号登录按钮)
        if res2:
            sleep(5)
        click_by_image(obj_info.主页面__托管弹窗__托管预览按钮)
        click_by_image(obj_info.主页面__托管弹窗__进入游戏按钮)
        click_by_image(obj_info.登录页面__默认__进入游戏按钮)
        sleep(3)

        click_by_image(obj_info.区组选择页__默认页面2__已有角色选项)
        click_by_image(obj_info.区组选择页__默认页面__默认区组, obj_info.区组选择页__默认页面__区组标题)
        sleep(3)
        click_by_image(obj_info.区组选择页__默认页面__默认人物, obj_info.区组选择页__默认页面__区组标题)

        # click_by_image(obj_info.主页面__离线刷道奖励领取弹窗__取消按钮,
        #                obj_info.主页面__离线刷道奖励领取弹窗__离线刷道文案)
        click_by_image(obj_info.区组选择页__登录确认弹窗__确认按钮)
        click_by_image(obj_info.区组选择页__登录确认弹窗2__确认按钮)

        # click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)

        res = click_by_image(obj_info.主页面__默认__人物头像区域, obj_info.主页面__默认__刷道按钮)
        if res:
            sleep(0.5)
            if is_exsit(obj_info.主页面__人物信息弹窗_水系账号__编号区域):
                ret = "水系账号"
                logger.info(f"账号类型:{res}")
                res = click_by_image(obj_info.主页面__人物信息弹窗__关闭按钮)
                if res:
                    return ret
            if is_exsit(obj_info.主页面__人物信息弹窗_木系账号__编号区域):
                ret = "木系账号"
                logger.info(f"账号类型:{res}")
                res = click_by_image(obj_info.主页面__人物信息弹窗__关闭按钮)
                if res:
                    return ret
            if is_exsit(obj_info.主页面__人物信息弹窗_火系账号__编号区域):
                ret = "火系账号"
                logger.info(f"账号类型:{res}")
                res = click_by_image(obj_info.主页面__人物信息弹窗__关闭按钮)
                if res:
                    return ret


@count_exec_time
def 离开队伍(timeout=60 * 5):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.主页面__对话框_默认__关闭按钮)  # 容错

        if is_exsit(obj_info.主页面__默认_未组队__创建队伍按钮):
            return True

        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)

        click_by_image(obj_info.主页面__默认_选中任务按钮__队伍按钮)
        click_by_image(obj_info.主页面__默认_选中组队按钮__队伍按钮)

        res = is_exsit(obj_info.主页面__队伍弹窗_默认__离开队伍按钮)

        if not res:
            click_by_image(obj_info.战斗中页面__默认__展开按钮)
            click_by_image(obj_info.战斗中页面__菜单弹窗__队伍按钮)

        click_by_image(obj_info.主页面__队伍弹窗_默认__离开队伍按钮)
        click_by_image(obj_info.主页面__离开队伍确认弹窗__确认按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)

        if is_exsit(obj_info.主页面__队伍弹窗_未组队__创建队伍按钮):
            click_by_image(obj_info.主页面__队伍弹窗_默认__关闭按钮)
            return True
        if is_exsit(obj_info.主页面__默认_未组队__创建队伍按钮):
            click_by_image(obj_info.主页面__队伍弹窗_默认__关闭按钮)
            return True


@count_exec_time
def 离开队伍2():
    离开队伍()


@count_exec_time
def 参战宠物1(timeout=15):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.主页面__离线刷道奖励领取弹窗__取消按钮)

        if is_exsit(obj_info.主页面__默认__宠物血条区域):
            return True
        click_by_image(obj_info.主页面__默认_宠物未参战__宠物头像)
        click_by_image(obj_info.主页面__宠物信息弹窗_未参战__参战按钮)
        click_by_image(obj_info.主页面__宠物信息弹窗__关闭按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 参战宠物2(timeout=30):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        if is_exsit(obj_info.主页面__默认__宠物血条区域):
            return True
        click_by_image(obj_info.主页面__默认_宠物未参战__宠物头像)
        click_by_image(obj_info.主页面__宠物信息弹窗__宠物头像名称文案2, obj_info.主页面__宠物信息弹窗_未参战__参战按钮)
        click_by_image(obj_info.主页面__宠物信息弹窗_未参战__参战按钮)
        click_by_image(obj_info.主页面__宠物信息弹窗__关闭按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 宠物休息(timeout=30):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_bounds(*obj_info.主页面__默认_宠物未参战__宠物头像["bounds"])
        sleep(0.5)
        click_by_image(obj_info.主页面__宠物信息弹窗_已参战__休息按钮)
        click_by_image(obj_info.主页面__宠物信息弹窗__关闭按钮)

        if is_exsit(obj_info.主页面__默认_宠物未参战__宠物头像):
            click_by_image(obj_info.主页面__宠物信息弹窗__关闭按钮)
            return True


@count_exec_time
def 师门任务(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)

        os.environ["screenshot_path"] = ""
        if is_exsit(obj_info.主页面__活动弹窗_师门任务已完成__活动名称文案2):
            return True

        click_by_image(
            obj_info.主页面__活动弹窗_默认__前往按钮1, obj_info.主页面__活动弹窗_师门任务未完成__活动名称文案1
        )
        click_by_image(obj_info.主页面__师门任务对话框__速通师门任务按钮)
        click_by_image(obj_info.主页面__师门任务对话框2__速通师门任务按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 帮派任务(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        os.environ["screenshot_path"] = ""
        if is_over_100:
            if is_exsit(obj_info.主页面__活动弹窗_帮派任务已完成2__活动名称文案5):
                # 第5位是竞技场
                return True
        else:
            if is_exsit(obj_info.主页面__活动弹窗_帮派任务已完成__活动名称文案4):
                # 第4位是竞技场
                return True

        click_by_image(
            obj_info.主页面__活动弹窗_默认__前往按钮2, obj_info.主页面__活动弹窗_师门任务已完成__活动名称文案2
        )
        click_by_image(obj_info.主页面__帮派任务对话框__速通帮派任务按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
        click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)


@count_exec_time
def 竞技场(timeout=60 * 5):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        os.environ["screenshot_path"] = ""

        if is_over_100:
            if is_exsit(obj_info.主页面__活动弹窗_竞技场已完成2__活动名称文案5):
                # 第5位是助人为乐
                return True
        else:
            if is_exsit(obj_info.主页面__活动弹窗_竞技场已完成__活动名称文案4):
                # 第4位是助人为乐
                return True

        if is_over_100:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮5, obj_info.主页面__活动弹窗_帮派任务已完成2__活动名称文案5
            )
        else:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮4, obj_info.主页面__活动弹窗_帮派任务已完成__活动名称文案4
            )

        click_by_image(obj_info.主页面__竞技场对话框__竞技场按钮)
        click_by_image(obj_info.主页面__竞技场弹窗__挑战按钮1)
        click_by_image(obj_info.主页面__竞技场挑战确认弹窗__确认按钮)
        click_by_image(obj_info.战斗中页面__默认_未自动战斗__自动战斗按钮)
        click_by_image(obj_info.主页面__竞技场弹窗__关闭按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 助人为乐(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        os.environ["screenshot_path"] = ""

        if is_over_100:
            if is_exsit(obj_info.主页面__活动弹窗_助人为乐已完成2__活动名称文案5):
                # 第5位是帮派日常挑战
                return True
        else:
            if is_exsit(obj_info.主页面__活动弹窗_助人为乐已完成__活动名称文案4):
                # 第4位是帮派日常挑战
                return True

        if is_over_100:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮5, obj_info.主页面__活动弹窗_竞技场已完成2__活动名称文案5
            )
        else:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮4, obj_info.主页面__活动弹窗_竞技场已完成__活动名称文案4
            )

        click_by_image(obj_info.主页面__助人为乐对话框__速通助人为乐按钮)
        click_by_image(obj_info.主页面__助人为乐对话框2__我要经验奖励按钮)
        click_by_image(obj_info.主页面__助人为乐对话框3__我要经验奖励按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 帮派日常挑战(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        os.environ["screenshot_path"] = ""

        if is_over_100:
            if is_exsit(obj_info.主页面__活动弹窗_帮派日常挑战已完成2__活动名称文案5):
                # 第5位是刷道
                return True
        else:
            if is_exsit(obj_info.主页面__活动弹窗_帮派日常挑战已完成__活动名称文案4):
                # 第4位是刷道
                return True

        if is_over_100:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮5, obj_info.主页面__活动弹窗_助人为乐已完成2__活动名称文案5
            )
        else:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮4, obj_info.主页面__活动弹窗_助人为乐已完成__活动名称文案4
            )
        click_by_image(obj_info.主页面__帮派日常挑战对话框__速通帮派挑战按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 通天塔(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        os.environ["screenshot_path"] = ""
        if is_over_100:
            if is_exsit(obj_info.主页面__活动弹窗_通天塔已完成2__活动名称文案7):
                # 第7位是斗宠大会
                return True
        else:
            if is_exsit(obj_info.主页面__活动弹窗_通天塔已完成__活动名称文案6):
                # 第6位是斗宠大会
                return True

        if is_over_100:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮7, obj_info.主页面__活动弹窗_帮派日常挑战已完成2__活动名称文案7
            )
        else:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮6, obj_info.主页面__活动弹窗_帮派日常挑战已完成__活动名称文案6
            )

        click_by_image(obj_info.主页面__通天塔对话框__速通所有层按钮)
        click_by_image(obj_info.主页面__通天塔对话框3__速通所有层按钮)
        click_by_image(obj_info.主页面__通天塔对话框2__经验奖励按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 修法任务(timeout=60 * 2):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        if is_exsit(obj_info.主页面__活动弹窗_第五位是引魂入殿__活动名称文案5):
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            # 第5位是引魂入殿
            return True

        click_by_image(
            obj_info.主页面__活动弹窗_第四位是修法任务__前往按钮4, obj_info.主页面__活动弹窗_第四位是修法任务__活动名称文案4
        )
        click_by_image(
            obj_info.主页面__活动弹窗_第五位是修法任务__前往按钮5, obj_info.主页面__活动弹窗_第五位是修法任务__活动名称文案5
        )
        click_by_image(
            obj_info.主页面__活动弹窗_第六位是修法任务__前往按钮6, obj_info.主页面__活动弹窗_第六位是修法任务__活动名称文案6
        )

        click_by_image(obj_info.主页面__修法任务对话框__速通修法任务按钮)
        click_by_image(obj_info.主页面__修法任务对话框2__速通修法任务按钮)
        click_by_image(obj_info.主页面__修法任务对话框3__不提交紫气鸿蒙按钮)

        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            swipe(719, 480, 719, 140, 500)
            sleep(1)
            swipe(719, 480, 719, 140, 500)
            sleep(1)
            swipe(719, 480, 719, 140, 500)
            sleep(1)

        if is_exsit(obj_info.主页面__活动弹窗_已滑动到底部_第三位是修法任务__活动名称文案3):
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            return True
        if is_exsit(obj_info.主页面__活动弹窗_已滑动到底部_第四位是修法任务__活动名称文案4):
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            return True
        if is_exsit(obj_info.主页面__活动弹窗_已滑动到底部_第五位是修法任务__活动名称文案5):
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            return True

        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 阵营战地图进入(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__活动弹窗_默认__限时活动按钮)

        click_by_image(
            obj_info.主页面__活动弹窗_限时活动_第一位是阵营战__前往按钮1,
            obj_info.主页面__活动弹窗_限时活动_第一位是阵营战__活动名称文案1,
        )
        click_by_image(
            obj_info.主页面__活动弹窗_限时活动_第二位是阵营战__前往按钮2,
            obj_info.主页面__活动弹窗_限时活动_第二位是阵营战__活动名称文案2,
        )

        click_by_image(obj_info.主页面__阵营活动弹窗__前往按钮1)

        click_by_image(obj_info.主页面__封神秘策对话框__前往阵营战按钮)

        click_by_image(obj_info.主页面__阵营战地图_提醒弹窗__知道了按钮)

        res = is_exsit(obj_info.主页面__阵营战地图__阵营活动按钮)
        if res:
            click_by_image(obj_info.主页面__阵营活动弹窗__关闭按钮)
            break
        click_by_image(obj_info.主页面__阵营活动弹窗__关闭按钮)
        click_by_image(obj_info.主页面__冥界地图弹窗__关闭按钮)


@count_exec_time
def 阵营战地图返回(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.主页面__阵营战地图__地图按钮)
        res = click_by_image(obj_info.主页面__阵营战地图_地图弹窗__去天界按钮)
        if res:
            sleep(5)
        click_by_image(obj_info.主页面__离线刷道奖励领取弹窗__取消按钮)

        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)

        click_by_image(obj_info.主页面__封神秘策弹窗2__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗2__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗2__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗2__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗2__全部领取按钮)

        click_by_image(obj_info.主页面__封神秘策奖励弹窗__点击继续按钮)

        click_by_image(obj_info.主页面__封神秘策弹窗2__历练策选项)
        sleep(0.5)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)

        click_by_image(obj_info.主页面__封神秘策弹窗__成长策选项)
        sleep(0.5)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗__全部领取按钮)

        click_by_image(obj_info.主页面__封神秘策弹窗__通神策选项)
        sleep(0.5)
        click_by_image(obj_info.主页面__封神秘策弹窗2__全部领取按钮)
        click_by_image(obj_info.主页面__封神秘策奖励弹窗__点击继续按钮)

        click_by_image(obj_info.主页面__封神秘策弹窗__奋战策选项)
        sleep(0.5)
        click_by_image(obj_info.主页面__封神秘策弹窗_奋战策__领取按钮1)
        click_by_image(obj_info.主页面__奋战策奖励弹窗__关闭按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗_奋战策__领取按钮1)
        click_by_image(obj_info.主页面__奋战策奖励弹窗__关闭按钮)
        click_by_image(obj_info.主页面__封神秘策弹窗_奋战策__领取按钮1)
        click_by_image(obj_info.主页面__奋战策奖励弹窗__关闭按钮)

        click_by_image(obj_info.主页面__封神秘策弹窗__关闭按钮)

        res = is_exsit(obj_info.主页面__默认__活动按钮)
        if res:
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            break
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 阵营战任务(timeout=60 * 10):
    timestamp_start = get_timestamp_unix()
    timestamp_day = get_timestamp()[6:8]

    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)

        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__阵营战地图__阵营活动按钮)
        if res:
            sleep(0.5)
        if is_exsit(obj_info.主页面__阵营活动弹窗_第一位是百战之将__活动文案1):
            click_by_image(obj_info.主页面__阵营活动弹窗__关闭按钮)
            return True
        click_by_image(obj_info.主页面__阵营活动弹窗__前往按钮1)

        res = is_exsit(obj_info.主页面__阵营战对话框_双排按钮__按钮左边框)
        if res:
            click_by_bounds(*obj_info.主页面__阵营战对话框_双排按钮__选项1["bounds"])

        # click_by_image(obj_info.主页面__阵营战对话框_正有此意__正有此意按钮)
        res = is_exsit(obj_info.主页面__阵营战对话框_军需问题__按钮左边框)
        if res:
            random_num = random.randint(1, 3)
            if random_num == 1:
                click_by_bounds(*obj_info.主页面__阵营战对话框_军需问题__选项1["bounds"])
            elif random_num == 2:
                click_by_bounds(*obj_info.主页面__阵营战对话框_军需问题__选项2["bounds"])
            else:
                click_by_bounds(*obj_info.主页面__阵营战对话框_军需问题__选项3["bounds"])

        click_by_image(obj_info.主页面__阵营战对话框_离开__离开按钮)
        click_by_image(obj_info.主页面__对话框_跳过__跳过按钮)
        click_by_image(obj_info.主页面__对话框_跳过__跳过按钮)

        click_by_image(obj_info.主页面__阵营活动弹窗__关闭按钮)


@count_exec_time
def 斗宠大会(timeout=60 * 10):
    timestamp_start = get_timestamp_unix()
    timestamp_day = get_timestamp()[6:8]

    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        os.environ["screenshot_path"] = ""
        if is_over_100:
            if is_exsit(obj_info.主页面__活动弹窗_斗宠大会已完成2__活动名称文案7):
                # 第7位是八仙梦境
                return True
        else:
            if is_exsit(obj_info.主页面__活动弹窗_斗宠大会已完成__活动名称文案6):
                # 第6位是八仙梦境
                return True

        if is_over_100:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮7, obj_info.主页面__活动弹窗_通天塔已完成2__活动名称文案7
            )
        else:
            click_by_image(
                obj_info.主页面__活动弹窗_默认__前往按钮6, obj_info.主页面__活动弹窗_通天塔已完成__活动名称文案6
            )

        click_by_image(obj_info.主页面__斗宠大会对话框__参加斗宠大会按钮)

        click_by_image(obj_info.主页面__斗宠大会对话框2__领取斗宠奖励按钮)
        click_by_image(obj_info.主页面__斗宠大会对话框3__领取奖励按钮, obj_info.主页面__斗宠大会对话框3__说明文案)
        click_by_image(obj_info.主页面__斗宠大会领取奖励确认弹窗__确认按钮)
        click_by_image(obj_info.主页面__斗宠大会领取奖励确认弹窗2__确认按钮)

        if timestamp_day == "01" or timestamp_day == "15":
            click_by_image(obj_info.主页面__斗宠大会弹窗__挑战按钮1)
        elif timestamp_day == "02" or timestamp_day == "16":
            click_by_image(obj_info.主页面__斗宠大会弹窗__挑战按钮2)
        elif timestamp_day == "03" or timestamp_day == "17":
            click_by_image(obj_info.主页面__斗宠大会弹窗__挑战按钮3)
        else:
            click_by_image(obj_info.主页面__斗宠大会弹窗__挑战按钮4)
        click_by_image(obj_info.主页面__斗宠大会_发起挑战确认弹窗__确认按钮)
        click_by_image(obj_info.战斗中页面__斗宠大会_可跳过__跳过按钮)
        click_by_image(obj_info.战斗中页面__斗宠大会_不可跳过__逃跑按钮)
        click_by_image(obj_info.主页面__斗宠大会弹窗__关闭按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 魔龙之祸(timeout=60 * 5):
    timestamp_start = get_timestamp_unix()
    count = -1
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        count += 1
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        是否做地宫 = False
        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
            if is_over_100:
                swipe(719, 500, 719, 200, 2000)
            else:
                swipe(719, 400, 719, 200, 2000)
            sleep(5)

            os.environ["screenshot_path"] = ""

            if count % 3 == 0:
                click_by_image(
                    obj_info.主页面__活动弹窗_已向下滑动2__前往按钮5, obj_info.主页面__活动弹窗_默认__弹窗标题
                )
                sleep(8)
            if count % 3 == 1:
                click_by_image(
                    obj_info.主页面__活动弹窗_已向下滑动__前往按钮6, obj_info.主页面__活动弹窗_默认__弹窗标题
                )
                sleep(8)
            if count % 3 == 2:
                click_by_image(
                    obj_info.主页面__活动弹窗_已向下滑动2__前往按钮4, obj_info.主页面__活动弹窗_默认__弹窗标题
                )
                sleep(8)
        click_by_image(obj_info.主页面__魔龙之祸对话框__速通魔龙之祸按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
        click_by_image(obj_info.主页面__封神秘策对话框__关闭按钮)
        click_by_image(obj_info.主页面__对话框_默认__关闭按钮)
        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
            swipe(719, 400, 719, 200, 50)
            sleep(2)
            swipe(719, 400, 719, 200, 50)
            sleep(2)

            res = is_exsit(obj_info.主页面__活动弹窗_魔龙之祸已完成_已滑动到底部_未做地宫__任务文案6)
            res2 = is_exsit(obj_info.主页面__活动弹窗_魔龙之祸已完成_已滑动到底部_未做地宫__任务状态6)
            if res and res2:
                break

            res = is_exsit(obj_info.主页面__活动弹窗_魔龙之祸已完成_已滑动到底部2__任务文案5)
            res2 = is_exsit(obj_info.主页面__活动弹窗_魔龙之祸已完成_已滑动到底部2__任务状态5)
            if res and res2:
                break

        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 引魂入殿(timeout=60 * 10):
    timestamp_start = get_timestamp_unix()
    count = -1
    是否使用过移形卡 = False
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        count += 1
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
            click_by_image(
                obj_info.主页面__活动弹窗_引魂入殿是第五位__前往按钮5, obj_info.主页面__活动弹窗_引魂入殿是第五位__活动名称文案5
            )
            if is_over_100:
                swipe(719, 500, 719, 200, 2000)
            else:
                swipe(719, 400, 719, 200, 2000)
            sleep(5)
            init_screenshot_path()
            if count % 3 == 0:
                click_by_image(
                    obj_info.主页面__活动弹窗_已向下滑动__前往按钮3, obj_info.主页面__活动弹窗_默认__弹窗标题
                )
                sleep(15)
            if count % 3 == 1:
                click_by_image(
                    obj_info.主页面__活动弹窗_已向下滑动__前往按钮4, obj_info.主页面__活动弹窗_默认__弹窗标题
                )
                sleep(15)
            if count % 3 == 2:
                click_by_image(
                    obj_info.主页面__活动弹窗_已向下滑动__前往按钮5, obj_info.主页面__活动弹窗_默认__弹窗标题
                )
                sleep(15)

        res = click_by_image(obj_info.主页面__引魂入殿对话框__引魂入殿按钮)
        if res:
            sleep(3)
        if 是否使用过移形卡 == False:
            res = click_by_image(obj_info.主页面__引魂入殿页面__移形卡按钮)
            if res:
                是否使用过移形卡 = True
        click_by_image(obj_info.主页面__引魂入殿页面_特殊任务1_确认退出弹窗__确认退出按钮)  # 确认使用
        click_by_image(obj_info.主页面__引魂入殿页面__引魂幡按钮)
        click_by_image(obj_info.主页面__对话框_跳过__跳过按钮)
        click_by_image(obj_info.主页面__对话框_跳过__跳过按钮)
        click_by_image(obj_info.主页面__引魂入殿_奖励页面__继续按钮, obj_info.主页面__引魂入殿_奖励页面__恭喜获得文案)
        click_by_image(obj_info.主页面__引魂入殿页面_特殊任务1__返回按钮)
        click_by_image(obj_info.主页面__引魂入殿页面_特殊任务2__返回按钮)
        click_by_image(obj_info.主页面__引魂入殿页面_特殊任务1_确认退出弹窗__确认退出按钮)
        click_by_image(obj_info.主页面__引魂入殿_赌鬼弹窗__我只是路过按钮)
        click_by_image(obj_info.主页面__对话框_默认__关闭按钮)
        click_by_image(obj_info.主页面__封神秘策对话框__关闭按钮)

        res = is_exsit(obj_info.主页面__引魂入殿页面_已无次数__次数区域, is_reduce_noise=True)
        if res:
            sleep(5)
            res2 = click_by_image(
                obj_info.主页面__引魂入殿页面__返回按钮, is_reduce_noise=True
            )  # 返回按钮识别不了？2023-01-31
            # res2 = click_by_image(obj_info.主页面__引魂入殿页面__返回按钮)
            if res2:
                sleep(5)
                # 使用宝箱
                click_by_image(obj_info.主页面__刷道卷轴使用弹窗__使用按钮)
                click_by_image(obj_info.主页面__刷道令使用确认弹窗__使用按钮)
                break
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
        click_by_image(obj_info.主页面__默认__活动按钮)
        res = is_exsit(obj_info.主页面__活动弹窗_默认__弹窗标题)
        if res:
            sleep(0.5)
            swipe(719, 400, 719, 200, 50)
            sleep(2)
            swipe(719, 400, 719, 200, 50)
            sleep(2)
            res = is_exsit(obj_info.主页面__活动弹窗_已滑动到底部_引魂入殿已完成__活动文案4)
            if res:
                break
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 名人膜拜(timeout=60 * 5):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.主页面__默认__活动按钮)
        sleep(0.5)
        res = click_by_image(obj_info.主页面__活动弹窗_默认2__其他活动按钮)
        res2 = click_by_image(obj_info.主页面__活动弹窗_默认__其他活动按钮)
        if res or res2:
            sleep(0.5)
            swipe(719, 400, 719, 200, 50)
            sleep(2)
            swipe(719, 400, 719, 200, 50)
            sleep(2)

            res = is_exsit(obj_info.主页面__活动弹窗_名人膜拜已完成_已向下滑动__任务文案6)
            res2 = is_exsit(obj_info.主页面__活动弹窗_名人膜拜已完成_已向下滑动__任务状态6)
            if res and res2:
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break

            res = is_exsit(obj_info.主页面__活动弹窗_名人膜拜已完成_已向下滑动2__任务文案5)
            res2 = is_exsit(obj_info.主页面__活动弹窗_名人膜拜已完成_已向下滑动2__任务状态5)
            if res and res2:
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break

        click_by_image(
            obj_info.主页面__活动弹窗_其他活动_已滑动到底部__前往按钮4, obj_info.主页面__活动弹窗_其他活动_已滑动到底部__活动文案4
        )
        click_by_image(
            obj_info.主页面__活动弹窗_其他活动_已滑动到底部2__前往按钮3,
            obj_info.主页面__活动弹窗_其他活动_已滑动到底部2__活动文案3,
        )
        sleep(3)
        res = is_exsit(obj_info.主页面__名人膜拜页面__关闭按钮)
        if res:
            click_by_bounds(*obj_info.主页面__名人膜拜页面__人物1["bounds"])
            click_by_bounds(*obj_info.主页面__名人膜拜页面_已点击人物1__膜拜按钮["bounds"])
            click_by_bounds(*obj_info.主页面__名人膜拜页面__人物2["bounds"])
            click_by_bounds(*obj_info.主页面__名人膜拜页面_已点击人物2__膜拜按钮["bounds"])
            click_by_bounds(*obj_info.主页面__名人膜拜页面__人物3["bounds"])
            click_by_bounds(*obj_info.主页面__名人膜拜页面_已点击人物3__膜拜按钮["bounds"])

            click_by_image(obj_info.主页面__名人膜拜页面__关闭按钮)
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            break
        click_by_image(obj_info.主页面__名人膜拜页面__关闭按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)

        # @count_exec_time
        # def 领取奖励(timeout=60):
        #     timestamp_start = get_timestamp_unix()
        #     while True:

        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)


#         time_spent = int(get_timestamp_unix()) - int(timestamp_start)
#         if time_spent > timeout:
#             break
#
#         timestamp_min = get_timestamp()[-4:-2]
#         if 30 > int(timestamp_min) > 39:
#             break
#
#         click_by_image(obj_info.主页面__默认__活动按钮)
#         sleep(0.5)
#         os.environ['screenshot_path'] = ""
#
#         click_by_image(obj_info.主页面__活动弹窗_未领取元宝__元宝图标)
#
#
#
#         click_by_image(obj_info.主页面__活动弹窗_限时活动__前往按钮1, obj_info.主页面__活动弹窗_限时活动__活动名称文案1)
#         click_by_image(obj_info.主页面__悬赏任务对话框__领取悬赏任务按钮)
#         if is_exsit(obj_info.主页面__双倍确认弹窗__确认按钮):
#             return True


@count_exec_time
def 打开双倍(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__巡逻按钮)
        if res:
            sleep(0.5)
        if is_exsit(obj_info.主页面__巡逻弹窗_已打开双倍__双倍开关):
            click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)
            return True
        click_by_image(obj_info.主页面__巡逻弹窗_已关闭双倍__双倍开关)
        click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)


@count_exec_time
def 关闭双倍(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__巡逻按钮)
        if res:
            sleep(0.5)
        if is_exsit(obj_info.主页面__巡逻弹窗_已关闭双倍__双倍开关):
            click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)
            return True
        click_by_image(obj_info.主页面__巡逻弹窗_已打开双倍__双倍开关)
        click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)


@count_exec_time
def 技能防御(timeout=60 * 3):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__巡逻按钮)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__巡逻弹窗_默认__人物技能图标)
        click_by_image(obj_info.主页面__巡逻弹窗_人物技能弹窗__防御技能)

        click_by_image(obj_info.主页面__巡逻弹窗_默认__宠物技能图标)
        sleep(0.5)
        click_by_image(obj_info.主页面__巡逻弹窗_宠物技能弹窗__二阶技能)
        click_by_image(obj_info.主页面__巡逻弹窗_宠物技能弹窗2__二阶技能)
        sleep(0.5)
        if is_exsit(obj_info.主页面__巡逻弹窗_技能已防御__人物技能):
            if is_exsit(obj_info.主页面__巡逻弹窗_技能已防御__宠物技能):
                click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)
                return True
        click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)


@count_exec_time
def 技能攻击(timeout=60 * 3):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__巡逻按钮)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__巡逻弹窗_默认__人物技能图标)
        click_by_image(obj_info.主页面__巡逻弹窗_人物技能弹窗__组合技能)

        click_by_image(obj_info.主页面__巡逻弹窗_默认__宠物技能图标)
        click_by_image(obj_info.主页面__巡逻弹窗_宠物技能弹窗__二阶技能)
        click_by_image(obj_info.主页面__巡逻弹窗_宠物技能弹窗2__二阶技能)

        sleep(0.5)
        if is_exsit(obj_info.主页面__巡逻弹窗_技能已攻击__人物技能):
            if is_exsit(obj_info.主页面__巡逻弹窗_技能已防御__宠物技能):
                click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)
                return True
        click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)


@count_exec_time
def 关闭刷道道具(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__刷道按钮)
        if res:
            sleep(0.5)
        # click_by_image(obj_info.主页面__刷道弹窗_道具已开启__紫气鸿蒙开关)
        # click_by_image(obj_info.主页面__刷道弹窗_道具已开启__急急如律令开关)
        # click_by_image(obj_info.主页面__刷道弹窗_道具已开启__宠风散开关)
        click_by_image(obj_info.主页面__刷道弹窗_道具已开启__如意刷道领开关)

        # res = is_exsit(obj_info.主页面__刷道弹窗_道具已关闭__紫气鸿蒙开关)
        # res2 = is_exsit(obj_info.主页面__刷道弹窗_道具已关闭__急急如律令开关)
        # res3 = is_exsit(obj_info.主页面__刷道弹窗_道具已关闭__宠风散开关)
        res4 = is_exsit(obj_info.主页面__刷道弹窗_道具已关闭__如意刷道领开关)

        if res4:
            click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)
            return True
        click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)


@count_exec_time
def 关闭高托自动匹配(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__刷道按钮)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__刷道弹窗__托管选项)

        res = is_exsit(obj_info.主页面__刷道弹窗_托管页面_已选中否___自动离队否选项)
        if res:
            click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)
            return True

        click_by_image(obj_info.主页面__刷道弹窗_托管页面__自动离队否选项)
        click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)


@count_exec_time
def 打开驱魔香(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__巡逻按钮)
        if res:
            sleep(0.5)
        if is_exsit(obj_info.主页面__巡逻弹窗_已打开驱魔香__驱魔香开关):
            click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)
            return True
        click_by_image(obj_info.主页面__巡逻弹窗_已关闭驱魔香__驱魔香开关)
        click_by_image(obj_info.主页面__巡逻弹窗_默认__关闭按钮)


@count_exec_time
def 领取悬赏任务(timeout=60 * 3):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        timestamp_min = get_timestamp()[-4:-2]
        logger.info("等待领取悬赏任务")
        if int(timestamp_min) > 40:
            break
        if int(timestamp_min) >= 30:
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)

            click_by_image(obj_info.主页面__默认_选中组队按钮__任务按钮)
            click_by_image(obj_info.主页面__默认_选中任务按钮__任务按钮)

            res = is_exsit(obj_info.主页面__任务弹窗_悬赏任务已领取__悬赏任务选项)
            if res:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res = is_exsit(obj_info.主页面__任务弹窗_悬赏任务已领取2__悬赏任务选项)
            if res:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res = is_exsit(obj_info.主页面__任务弹窗_悬赏任务已领取3__悬赏任务选项)
            if res:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res = is_exsit(obj_info.主页面__任务弹窗_悬赏任务已完成__悬赏任务选项)
            if res:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res = is_exsit(obj_info.战斗中页面__默认_未自动战斗__自动战斗按钮)
            if res:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res = is_exsit(obj_info.主页面__悬赏任务对话框_悬赏任务已完成__领取奖励按钮)
            if res:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res = is_exsit(obj_info.主页面__任务弹窗_悬赏任务在第五位__任务选项5)
            if res:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res = is_exsit(obj_info.主页面__任务弹窗_悬赏任务在第六位__任务选项6)
            if res:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break

            click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)

            res = click_by_image(obj_info.主页面__默认__活动按钮)
            if res:
                res = False
                sleep(0.5)
            init_screenshot_path()
            click_by_image(obj_info.主页面__活动弹窗_默认__限时活动按钮)

            click_by_image(
                obj_info.主页面__活动弹窗_限时活动__前往按钮1, obj_info.主页面__活动弹窗_限时活动__活动名称文案1
            )
            click_by_image(
                obj_info.主页面__活动弹窗_限时活动2__前往按钮2, obj_info.主页面__活动弹窗_限时活动2__活动名称文案2
            )
            click_by_image(obj_info.主页面__悬赏任务对话框__领取悬赏任务按钮)
            click_by_image(obj_info.主页面__双倍确认弹窗__取消按钮)
            click_by_image(obj_info.主页面__双倍确认弹窗__取消按钮)  # 驱魔香提醒

            click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
        else:
            sleep(10)


@count_exec_time
def 悬赏任务(timeout=60 * 10):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.主页面__对话框_默认__关闭按钮)  # 魔龙之祸容错

        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        res = is_exsit(obj_info.主页面__活动弹窗_默认__弹窗标题)
        if res:
            click_by_image(obj_info.主页面__活动弹窗_默认__限时活动按钮)
            swipe(719, 480, 719, 140, 1000)
            sleep(2)
            swipe(719, 480, 719, 140, 1000)
            sleep(3)
            os.environ["screenshot_path"] = ""
            res1 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成__悬赏任务文案)
            res2 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成__悬赏任务状态)
            if res1 and res2:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res1 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成2__悬赏任务文案)
            res2 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成2__悬赏任务状态)
            if res1 and res2:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res1 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成3__悬赏任务文案)
            res2 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成3__悬赏任务状态)
            if res1 and res2:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res1 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成4__悬赏任务文案)
            res2 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成4__悬赏任务状态)
            if res1 and res2:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
            res1 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成5__悬赏任务文案)
            res2 = is_exsit(obj_info.主页面__活动弹窗_悬赏任务已完成5__悬赏任务状态)
            if res1 and res2:
                click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                break
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
        # click_by_image(obj_info.主页面__默认__活动按钮)
        # click_by_image(obj_info.主页面__活动弹窗_默认__限时活动按钮)
        # click_by_image(obj_info.主页面__活动弹窗_限时活动__前往按钮1, obj_info.主页面__活动弹窗_限时活动__活动名称文案1)
        sleep(0.5)
        click_by_image(obj_info.主页面__默认_选中组队按钮__任务按钮)
        click_by_image(obj_info.主页面__默认_选中任务按钮__任务按钮)
        sleep(0.5)
        res = is_exsit(obj_info.主页面__任务弹窗_默认__弹窗标题)
        res1 = click_by_image(obj_info.主页面__任务弹窗_已领取悬赏任务__悬赏任务选项)
        if res1:
            click_by_image(obj_info.主页面__任务弹窗_已选中悬赏任务__前往按钮)
        res2 = click_by_image(obj_info.主页面__任务弹窗_悬赏任务已完成__悬赏任务选项)
        if res2:
            click_by_image(obj_info.主页面__任务弹窗_已选中悬赏任务__前往按钮)

        res3 = click_by_image(obj_info.主页面__任务弹窗_悬赏任务已领取3__悬赏任务选项)
        if res3:
            click_by_image(obj_info.主页面__任务弹窗_已选中悬赏任务__前往按钮)

        res4 = click_by_image(obj_info.主页面__任务弹窗_悬赏任务在第六位__任务选项6)
        if res4:
            click_by_image(obj_info.主页面__任务弹窗_已选中悬赏任务__前往按钮)
        res5 = click_by_image(obj_info.主页面__任务弹窗_悬赏任务在第五位__任务选项5)
        if res5:
            click_by_image(obj_info.主页面__任务弹窗_已选中悬赏任务__前往按钮)

        if res and not res1 and not res2 and not res3 and not res4 and not res5:
            click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            break
        click_by_image(obj_info.战斗中页面__默认_未自动战斗__自动战斗按钮)
        click_by_image(obj_info.主页面__悬赏任务对话框_悬赏任务已完成__领取奖励按钮)
        click_by_image(obj_info.主页面__悬赏任务对话框_悬赏任务已完成2__经验奖励按钮)
        click_by_image(obj_info.主页面__任务弹窗_默认__关闭按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 是否等级大于100(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__人物头像区域, obj_info.主页面__默认__刷道按钮)
        if res:
            sleep(0.5)
            res = is_exsit(obj_info.主页面__人物信息弹窗__弹窗标题)
            if res:
                res = is_exsit(obj_info.主页面__人物信息弹窗__弹窗标题)
                res2 = is_exsit(obj_info.主页面__人物信息弹窗_大于100级__100级等级标识)
                click_by_image(obj_info.主页面__人物信息弹窗__关闭按钮)
                click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
                if res and res2:
                    return True
                if res and not res2:
                    return False

        click_by_image(obj_info.主页面__人物信息弹窗__关闭按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 活跃奖励(timeout=30):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.主页面__刷道卷轴使用弹窗__使用按钮)
        click_by_image(obj_info.主页面__刷道卷轴使用弹窗__使用按钮)
        click_by_image(obj_info.主页面__刷道卷轴使用弹窗__使用按钮)

        res = click_by_image(obj_info.主页面__默认__活动按钮)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__活动弹窗_活跃奖励未领取__元宝图标)
        click_by_image(obj_info.主页面__刷道卷轴使用弹窗__使用按钮)
        click_by_image(obj_info.主页面__刷道卷轴使用弹窗__使用按钮)
        click_by_image(obj_info.主页面__刷道卷轴使用弹窗__使用按钮)
        sleep(0.5)
        使用刷道领和卷轴()
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 每日签到(timeout=30):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break
        res = click_by_image(obj_info.主页面__默认__福利图标)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__福利弹窗_默认__每日签到选项)
        res2 = click_by_image(obj_info.主页面__福利弹窗_默认4__每日签到选项)
        if res or res2:
            click_by_bounds(*obj_info.主页面__福利弹窗_默认__签到区域["bounds"], step=50)
        sleep(0.5)
        click_by_bounds(*obj_info.主页面__福利弹窗_默认__关闭按钮["bounds"])
        click_by_bounds(*obj_info.主页面__福利弹窗_默认__关闭按钮["bounds"])


@count_exec_time
def 神秘大礼(timeout=30):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__福利图标)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__福利弹窗_默认__神秘大礼选项)
        click_by_image(obj_info.主页面__福利弹窗_默认2__神秘大礼选项)
        click_by_image(obj_info.主页面__福利弹窗_默认5__神秘大礼选项)

        res = click_by_image(obj_info.主页面__福利弹窗_神秘大礼页面__全部砸开按钮)
        if res:
            click_by_image(obj_info.主页面__福利弹窗_默认__关闭按钮)
            break
        click_by_image(obj_info.主页面__福利弹窗_默认__关闭按钮)


def 神秘大礼2():
    神秘大礼()


@count_exec_time
def 月道福运(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__福利图标)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__福利弹窗_默认__月道福运选项)
        click_by_image(obj_info.主页面__福利弹窗_默认2__月道福运选项)
        click_by_image(obj_info.主页面__福利弹窗_默认3__月道福运选项)
        click_by_image(obj_info.主页面__福利弹窗_默认4__月道福运选项)
        res = click_by_image(obj_info.主页面__福利弹窗_月道福运_未领取__奖励1)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__福利弹窗_月道福运_未领取__奖励1)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__福利弹窗_月道福运_未领取__奖励1)
        if res:
            sleep(0.5)

        res = is_exsit(obj_info.主页面__福利弹窗_月道福运_已领取__奖励1)
        if res:
            click_by_image(obj_info.主页面__福利弹窗_默认__关闭按钮)
            break
        click_by_image(obj_info.主页面__福利弹窗_默认__关闭按钮)


@count_exec_time
def 月道福运2(timeout=60):
    月道福运()


@count_exec_time
def 造化之池(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__福利图标)
        if res:
            sleep(0.5)
        swipe(308, 500, 308, 200, 300)
        sleep(1)
        click_by_image(obj_info.主页面__福利弹窗_已滑动到底部__造化之池选项)
        click_by_image(obj_info.主页面__福利弹窗_已滑动到底部2__造化之池选项)
        click_by_image(obj_info.主页面__福利弹窗_已滑动到底部3__造化之池选项)
        click_by_image(obj_info.主页面__福利弹窗_造化之池页面_造化之池未吸收__吸收按钮)
        click_by_image(obj_info.主页面__福利弹窗_造化之池页面_造化之池未吸收__吸收按钮)
        if is_exsit(obj_info.主页面__福利弹窗_造化之池页面_造化之池已吸收__可吸收次数):
            click_by_image(obj_info.主页面__福利弹窗_默认__关闭按钮)
            return True
        click_by_image(obj_info.主页面__福利弹窗_默认__关闭按钮)


@count_exec_time
def 升级福利(timeout=60 * 2):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__福利图标)
        if res:
            sleep(0.5)
            swipe(308, 500, 308, 200, 300)
            sleep(1)
        res = click_by_image(obj_info.主页面__福利弹窗_已滑动到底部4__升级福利选项)
        sleep(1)
        click_by_image(obj_info.主页面__福利弹窗_升级福利页面__领取按钮)
        sleep(1)
        click_by_image(obj_info.主页面__福利弹窗_升级福利页面__领取按钮)

        if res:
            swipe(753, 500, 753, 200, 300)
            sleep(3)
        if is_exsit(obj_info.主页面__福利弹窗_升级福利页面_已滑动到底部_经验奖励已领取__活跃度奖励区域):
            click_by_image(obj_info.主页面__福利弹窗_默认__关闭按钮)
            break
        if is_exsit(obj_info.主页面__福利弹窗_升级福利页面_已滑动到底部_经验奖励已领取2__活跃度奖励区域):
            click_by_image(obj_info.主页面__福利弹窗_默认__关闭按钮)
            break
        click_by_image(obj_info.主页面__福利弹窗_默认__关闭按钮)


@count_exec_time
def 会员元宝(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)

        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__商城图标)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__商城弹窗_默认__会员选项)
        click_by_image(obj_info.主页面__商城弹窗_会员页面__领取按钮)
        if is_exsit(obj_info.主页面__商城弹窗_会员页面_已领取__已领取按钮):
            click_by_image(obj_info.主页面__商城弹窗_默认__关闭按钮)
            return True
        click_by_image(obj_info.主页面__商城弹窗_默认__关闭按钮)


@count_exec_time
def 领取刷道积分奖励(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__刷道按钮)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__刷道弹窗__积分选项)

        click_by_image(obj_info.主页面__刷道弹窗_积分页面__一键领取按钮)
        if is_exsit(obj_info.主页面__刷道弹窗_积分页面_已领取__一键领取按钮):
            click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)
            return True
        click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)


@count_exec_time
def 全局刷道积分奖励(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__刷道按钮)
        if res:
            sleep(0.5)
        click_by_image(obj_info.主页面__刷道弹窗__积分选项)
        res = click_by_image(obj_info.主页面__刷道弹窗_积分页面__全局积分选项)
        if res:
            click_by_image(obj_info.主页面__刷道弹窗_全局积分页面__一键兑换按钮)
            if is_exsit(obj_info.主页面__刷道弹窗_全局积分页面_已领取__一键兑换按钮):
                click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)
                return True
        click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)


@count_exec_time
def 使用刷道领和卷轴(timeout=15):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break
        click_by_image(obj_info.主页面__刷道弹窗__关闭按钮)
        click_by_image(obj_info.主页面__刷道卷轴使用弹窗__使用按钮)
        click_by_image(obj_info.主页面__刷道令使用确认弹窗__使用按钮)
        click_by_image(obj_info.主页面__刷道令使用确认弹窗2__使用按钮)
        click_by_image(obj_info.主页面__刷道卷轴使用确认弹窗__使用按钮)


def 使用刷道领和卷轴2():
    使用刷道领和卷轴()


@count_exec_time
def 神将装备穿戴(timeout=30):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__展开按钮)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__底部菜单已展开__洛书图标)
        if res:
            sleep(2)
        res = click_by_image(obj_info.主页面__洛书弹窗__神将选项)

        if res:
            click_by_bounds(*obj_info.主页面__洛书弹窗_神将页面__神将1["bounds"])
            click_by_image(obj_info.主页面__洛书弹窗_神将页面__一件穿戴按钮)
            click_by_bounds(*obj_info.主页面__洛书弹窗_神将页面__神将2["bounds"])
            click_by_image(obj_info.主页面__洛书弹窗_神将页面__一件穿戴按钮)
            click_by_bounds(*obj_info.主页面__洛书弹窗_神将页面__神将3["bounds"])
            click_by_image(obj_info.主页面__洛书弹窗_神将页面__一件穿戴按钮)
            click_by_bounds(*obj_info.主页面__洛书弹窗_神将页面__神将4["bounds"])
            click_by_image(obj_info.主页面__洛书弹窗_神将页面__一件穿戴按钮)
            click_by_bounds(*obj_info.主页面__洛书弹窗_神将页面__神将5["bounds"])

            res = click_by_image(obj_info.主页面__洛书弹窗_神将页面__一件穿戴按钮)
            if res:
                click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)
                break


@count_exec_time
def 神将装备穿戴2(timeout=30):
    神将装备穿戴()


@count_exec_time
def 军备库分解(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__展开按钮)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__底部菜单已展开__洛书图标)
        if res:
            sleep(3)

        click_by_image(obj_info.主页面__洛书弹窗__领取按钮)
        click_by_image(obj_info.主页面__洛书弹窗__洞天选项)

        click_by_image(obj_info.主页面__洛书弹窗_洞天页面__军备库图标)

        click_by_image(obj_info.主页面__洛书弹窗_军备库页面__分解按钮)
        click_by_image(obj_info.主页面__洛书弹窗_军备库页面_待勾选__一键勾选按钮)
        click_by_image(obj_info.主页面__洛书弹窗_军备库页面_已勾选__确认按钮)
        click_by_image(obj_info.主页面__洛书弹窗_军备库页面_确认提示__确认按钮)
        click_by_image(obj_info.主页面__洛书弹窗_军备库页面_确认提示__确认按钮)

        click_by_image(obj_info.主页面__洛书弹窗_军备库页面__分解按钮)
        click_by_image(obj_info.主页面__洛书弹窗_军备库页面_待勾选__一键勾选按钮)

        res = is_exsit(obj_info.主页面__洛书弹窗_军备库页面_已分解__确认按钮)
        res1 = is_exsit(obj_info.主页面__洛书弹窗_军备库页面_待勾选__一键勾选按钮)
        if res and res1:
            click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
            click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)
            break

        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
        click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)


@count_exec_time
def 洛书升级(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__展开按钮)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__底部菜单已展开__洛书图标)
        if res:
            sleep(2)

        click_by_image(obj_info.主页面__洛书弹窗__等级按钮)

        click_by_image(obj_info.主页面__洛书弹窗_等级弹窗__升级按钮)

        res = is_exsit(obj_info.主页面__洛书弹窗_等级弹窗_已升级__升级按钮)
        if res:
            click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
            click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)
            break

        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
        click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)


@count_exec_time
def 洛书升级2(timeout=60):
    洛书升级()


@count_exec_time
def 天工府领取(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__展开按钮)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__底部菜单已展开__洛书图标)
        if res:
            sleep(2)

        click_by_image(obj_info.主页面__洛书弹窗__领取按钮)

        click_by_image(obj_info.主页面__洛书弹窗__洞天选项)
        click_by_image(obj_info.主页面__洛书弹窗_洞天页面__天工府图标)
        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__领取按钮1)
        click_by_image(obj_info.主页面__洛书弹窗_天工物品领取确认提示__点击继续按钮)
        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__领取按钮2)
        click_by_image(obj_info.主页面__洛书弹窗_天工物品领取确认提示__点击继续按钮)
        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__领取按钮3)
        click_by_image(obj_info.主页面__洛书弹窗_天工物品领取确认提示__点击继续按钮)

        res = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_已领取__领取按钮1)
        res2 = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_已领取__领取按钮1)
        res3 = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_已领取__领取按钮1)
        if res and res2 and res3:
            click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
            click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)
            break

        res = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_造物中__时间图标1)
        res2 = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_造物中__时间图标2)
        res3 = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_造物中__时间图标3)
        if res and res2 and res3:
            click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
            click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)
            break

        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
        click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)


def 天工府领取2():
    天工府领取()


@count_exec_time
def 淬魂阁(timeout=30):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__展开按钮)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__底部菜单已展开__洛书图标)
        if res:
            sleep(2)

        click_by_image(obj_info.主页面__洛书弹窗__洞天选项)
        click_by_image(obj_info.主页面__洛书弹窗_洞天页面__淬魂阁图标)

        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__选项1)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__选项2)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__选项3)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__选项4)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__选项5)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__选项6)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)
        click_by_image(obj_info.主页面__洛书弹窗_淬魂阁页面__淬魂按钮)

        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
        click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)


@count_exec_time
def 淬魂阁2(timeout=30):
    淬魂阁()


@count_exec_time
def 聚神楼(timeout=60 * 3):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        for i in range(10):
            res = click_by_image(obj_info.主页面__默认__展开按钮)
            if res:
                sleep(0.5)
            res = click_by_image(obj_info.主页面__底部菜单已展开__洛书图标)
            if res:
                sleep(2)

            click_by_image(obj_info.主页面__洛书弹窗__洞天选项)
            res = click_by_image(obj_info.主页面__洛书弹窗_洞天页面__聚神楼图标)
            if res:
                res = is_exsit(obj_info.主页面__洛书弹窗_聚神楼页面_已无次数__妖魂个数)
                if res:
                    click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
                    click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)
                    return True
                for i in range(3):
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项1["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项2["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项3["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项4["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项5["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项6["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项7["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项8["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项9["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项10["bounds"])
                    click_by_bounds(*obj_info.主页面__洛书弹窗_聚神楼页面__选项11["bounds"])
                    sleep(0.5)
                    click_by_image(obj_info.主页面__洛书弹窗_聚神楼奖励弹窗__继续按钮)
        click_by_image(obj_info.主页面__洛书弹窗_聚神楼奖励弹窗__继续按钮)  # 容错
        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
        click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)


@count_exec_time
def 聚神楼2(timeout=60 * 3):
    聚神楼()


@count_exec_time
def 天工府造物(timeout=60 * 5):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__展开按钮)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__底部菜单已展开__洛书图标)
        if res:
            sleep(2)
        click_by_image(obj_info.主页面__洛书弹窗__洞天选项)
        click_by_image(obj_info.主页面__洛书弹窗_洞天页面__天工府图标)

        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_已领取__领取按钮1)
        click_by_image(obj_info.主页面__洛书弹窗_天工造物_选择神将页面__一键选择按钮)
        click_by_image(obj_info.主页面__洛书弹窗_天工造物_选择神将页面__开始按钮)
        click_by_image(obj_info.主页面__洛书弹窗_天工造物_确认弹窗__确认按钮)

        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_已领取__领取按钮2)
        click_by_image(obj_info.主页面__洛书弹窗_天工造物_选择神将页面__一键选择按钮)
        click_by_image(obj_info.主页面__洛书弹窗_天工造物_选择神将页面__开始按钮)
        click_by_image(obj_info.主页面__洛书弹窗_天工造物_确认弹窗__确认按钮)

        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_已领取__领取按钮3)
        click_by_image(obj_info.主页面__洛书弹窗_天工造物_选择神将页面__一键选择按钮)
        click_by_image(obj_info.主页面__洛书弹窗_天工造物_选择神将页面__开始按钮)
        click_by_image(obj_info.主页面__洛书弹窗_天工造物_确认弹窗__确认按钮)

        res = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_造物中__时间图标1)
        res2 = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_造物中__时间图标2)
        res3 = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_造物中__时间图标3)
        if res and res2 and res3:
            click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
            click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)
            break
        res = is_exsit(obj_info.主页面__洛书弹窗_天工府页面_剩余天火数为0__剩余天火个数)
        if res:
            click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
            click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)
            break
        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
        click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)


def 天工府造物2():
    天工府造物()


@count_exec_time
def 洛书试炼场(timeout=60 * 5):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__展开按钮)
        if res:
            sleep(0.5)
        res = click_by_image(obj_info.主页面__底部菜单已展开__洛书图标)
        if res:
            sleep(2)
        click_by_image(obj_info.主页面__洛书弹窗__洞天选项)

        click_by_image(obj_info.主页面__洛书弹窗_洞天页面__试炼场图标)

        click_by_image(obj_info.主页面__洛书弹窗_试炼场页面__妖魂试炼选项)
        # 一阶
        sleep(0.5)
        # click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼页面__一阶试炼速通按钮)
        click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼页面__二阶试炼速通按钮)
        click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼页面2__二阶试炼速通按钮)

        click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼确认速通弹窗__确认按钮)
        click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼确认弹窗__点击继续按钮)
        click_by_image(obj_info.主页面__洛书弹窗_试炼场页面__妖魂试炼选项)
        # click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼页面__一阶试炼速通按钮)
        click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼页面__二阶试炼速通按钮)
        click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼页面2__二阶试炼速通按钮)

        click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼确认速通弹窗__确认按钮)
        click_by_image(obj_info.主页面__洛书弹窗_妖魂试炼确认弹窗__点击继续按钮)
        click_by_image(obj_info.主页面__洛书弹窗_试炼场页面__妖魂试炼选项)
        res = is_exsit(obj_info.主页面__洛书弹窗_妖魂试炼页面_一阶试炼已完成__剩余奖励次数)
        if res:
            click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
            click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
            click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)
            break
        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
        click_by_image(obj_info.主页面__洛书弹窗_天工府页面_未领取__返回按钮)
        click_by_image(obj_info.主页面__洛书弹窗__关闭按钮)


@count_exec_time
def 洛书试炼场2(timeout=60 * 5):
    洛书试炼场()


@count_exec_time
def 洛书更换装备(timeout=60):
    pass


@count_exec_time
def 法宝补灵气(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__默认__背包按钮)
        if res:
            click_by_bounds(*obj_info.主页面__背包弹窗__法宝区域["bounds"])
            click_by_image(obj_info.主页面__背包弹窗_法宝弹窗__更多按钮)
            res = click_by_image(obj_info.主页面__背包弹窗_法宝弹窗2__补灵气按钮)
            if res:
                sleep(0.5)
                res = is_exsit(obj_info.主页面__背包弹窗_法宝弹窗2__补灵气按钮)
                if res:
                    click_by_image(obj_info.主页面__背包弹窗_法宝弹窗__卸下按钮)

            res = click_by_image(obj_info.主页面__背包弹窗_补灵气确认提示__确认按钮)
            if res:
                click_by_bounds(*obj_info.主页面__背包弹窗__法宝区域["bounds"])
                click_by_image(obj_info.主页面__背包弹窗_法宝弹窗__卸下按钮)

            # 未限制交易的法宝
            click_by_bounds(*obj_info.主页面__背包弹窗__法宝区域["bounds"])
            click_by_image(obj_info.主页面__背包弹窗_法宝弹窗3__更多按钮)
            res = click_by_image(obj_info.主页面__背包弹窗_法宝弹窗4__补灵气按钮)
            if res:
                sleep(0.5)
                res = is_exsit(obj_info.主页面__背包弹窗_法宝弹窗4__补灵气按钮)
                if res:
                    click_by_image(obj_info.主页面__背包弹窗_法宝弹窗3__卸下按钮)

            res = click_by_image(obj_info.主页面__背包弹窗_补灵气确认提示__确认按钮)
            if res:
                click_by_bounds(*obj_info.主页面__背包弹窗__法宝区域["bounds"])
                click_by_image(obj_info.主页面__背包弹窗_法宝弹窗3__卸下按钮)

        res = is_exsit(obj_info.主页面__背包弹窗_法宝已卸下__法宝区域)
        if res:
            click_by_image(obj_info.主页面__背包弹窗__关闭按钮)
            break
        click_by_image(obj_info.主页面__背包弹窗__关闭按钮)


@count_exec_time
def 使用药品(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.主页面__默认__背包按钮)
        sleep(0.5)
        res = click_by_image(obj_info.主页面__背包弹窗__整理按钮)
        if res:
            res = is_exsit(obj_info.主页面__背包弹窗_已整理__结婚纪念册区域)
            if res:
                # 已结婚账号
                click_by_image(obj_info.主页面__背包弹窗_已整理__药品1区域)
                click_by_image(obj_info.主页面__背包弹窗_药品1弹窗__使用按钮, timeout=500)
                click_by_image(obj_info.主页面__背包弹窗_使用确认提示__确认按钮)

                click_by_image(obj_info.主页面__背包弹窗_已整理__药品2区域)
                click_by_image(obj_info.主页面__背包弹窗_药品2弹窗__使用按钮, timeout=500)
                click_by_image(obj_info.主页面__背包弹窗_使用确认提示__确认按钮)

                click_by_image(obj_info.主页面__背包弹窗_已整理__药品3区域)
                click_by_image(obj_info.主页面__背包弹窗_药品3弹窗__使用按钮, timeout=500)
                click_by_image(obj_info.主页面__背包弹窗_使用确认提示__确认按钮)

                click_by_image(obj_info.主页面__背包弹窗_已整理__药品4区域)
                click_by_image(obj_info.主页面__背包弹窗_药品4弹窗__使用按钮, timeout=500)
                click_by_image(obj_info.主页面__背包弹窗_使用确认提示__确认按钮)

                count = 0
                res = is_exsit(obj_info.主页面__背包弹窗_已整理__药品1区域)
                if res:
                    count += 1
                res = is_exsit(obj_info.主页面__背包弹窗_已整理__药品2区域)
                if res:
                    count += 1
                res = is_exsit(obj_info.主页面__背包弹窗_已整理__药品3区域)
                if res:
                    count += 1
                res = is_exsit(obj_info.主页面__背包弹窗_已整理__药品4区域)
                if res:
                    count += 1

                if count <= 2:
                    click_by_image(obj_info.主页面__背包弹窗__关闭按钮)
                    break
            else:
                click_by_image(obj_info.主页面__背包弹窗_已整理2__药品1区域)
                click_by_image(obj_info.主页面__背包弹窗_药品1弹窗2__使用按钮, timeout=500)
                click_by_image(obj_info.主页面__背包弹窗_使用确认提示__确认按钮)

                click_by_image(obj_info.主页面__背包弹窗_已整理2__药品2区域)
                click_by_image(obj_info.主页面__背包弹窗_药品2弹窗2__使用按钮, timeout=500)
                click_by_image(obj_info.主页面__背包弹窗_使用确认提示__确认按钮)

                click_by_image(obj_info.主页面__背包弹窗_已整理2__药品3区域)
                click_by_image(obj_info.主页面__背包弹窗_药品3弹窗2__使用按钮, timeout=500)
                click_by_image(obj_info.主页面__背包弹窗_使用确认提示__确认按钮)

                click_by_image(obj_info.主页面__背包弹窗_已整理2__药品4区域)
                click_by_image(obj_info.主页面__背包弹窗_药品4弹窗2__使用按钮, timeout=500)
                click_by_image(obj_info.主页面__背包弹窗_使用确认提示__确认按钮)

                count = 0
                res = is_exsit(obj_info.主页面__背包弹窗_已整理2__药品1区域)
                if res:
                    count += 1
                res = is_exsit(obj_info.主页面__背包弹窗_已整理2__药品2区域)
                if res:
                    count += 1
                res = is_exsit(obj_info.主页面__背包弹窗_已整理2__药品3区域)
                if res:
                    count += 1
                res = is_exsit(obj_info.主页面__背包弹窗_已整理2__药品4区域)
                if res:
                    count += 1

                if count <= 2:
                    click_by_image(obj_info.主页面__背包弹窗__关闭按钮)
                    break
        click_by_image(obj_info.主页面__背包弹窗__关闭按钮)


@count_exec_time
def 武魂升级(timeout=60 * 3):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.主页面__默认__人物头像区域, obj_info.主页面__默认__刷道按钮)
        click_by_image(obj_info.主页面__人物信息弹窗__魂魄选项)

        click_by_image(obj_info.主页面__武魂弹窗__突破按钮)
        click_by_image(obj_info.主页面__武魂弹窗__突破按钮)
        click_by_image(obj_info.主页面__武魂弹窗__突破按钮)
        click_by_image(obj_info.主页面__武魂弹窗__突破按钮)
        click_by_image(obj_info.主页面__武魂弹窗__突破按钮)

        res = click_by_image(obj_info.主页面__武魂弹窗__魂窍按钮)
        if res:
            click_by_bounds(*obj_info.主页面__魂窍弹窗__魂窍1["bounds"])

        click_by_image(obj_info.主页面__魂窍弹窗__强化按钮)
        click_by_image(obj_info.主页面__武魂窍强化确认弹窗__确认按钮)
        click_by_image(obj_info.主页面__魂窍弹窗__强化按钮)
        click_by_image(obj_info.主页面__武魂窍强化确认弹窗__确认按钮)
        click_by_image(obj_info.主页面__魂窍弹窗__强化按钮)
        click_by_image(obj_info.主页面__武魂窍强化确认弹窗__确认按钮)
        click_by_image(obj_info.主页面__魂窍弹窗__强化按钮)
        click_by_image(obj_info.主页面__武魂窍强化确认弹窗__确认按钮)
        res = click_by_image(obj_info.主页面__魂窍弹窗__强化按钮)
        click_by_image(obj_info.主页面__武魂窍强化确认弹窗__确认按钮)
        if res:
            click_by_image(obj_info.主页面__魂窍弹窗__关闭按钮)
            click_by_image(obj_info.主页面__武魂弹窗__关闭按钮)
            break
        click_by_image(obj_info.主页面__魂窍弹窗__关闭按钮)
        click_by_image(obj_info.主页面__武魂弹窗__关闭按钮)


@count_exec_time
def 副本领取奖励(timeout=60 * 3):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        click_by_image(obj_info.主页面__默认__活动按钮)
        click_by_image(
            obj_info.主页面__活动弹窗_副本是第一位__前往按钮1, obj_info.主页面__活动弹窗_副本是第一位__活动名称文案1
        )
        click_by_image(
            obj_info.主页面__活动弹窗_副本是第二位__前往按钮2, obj_info.主页面__活动弹窗_副本是第二位__活动名称文案2
        )
        sleep(0.5)
        click_by_image(obj_info.主页面__副本对话框__领取奖励按钮)
        click_by_image(obj_info.主页面__副本对话框4__领取奖励按钮)

        res = click_by_image(obj_info.主页面__副本对话框2__经验奖励按钮)
        if res:
            click_by_image(obj_info.主页面__对话框_默认__关闭按钮)
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            break
        res = is_exsit(obj_info.主页面__副本对话框3__便捷组队按钮)
        if res:
            click_by_image(obj_info.主页面__对话框_默认__关闭按钮)
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            break
        res = is_exsit(obj_info.主页面__活动弹窗_第一位是刷道__活动名称文案1)
        if res:
            click_by_image(obj_info.主页面__对话框_默认__关闭按钮)
            click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)
            break
        click_by_image(obj_info.主页面__对话框_默认__关闭按钮)
        click_by_image(obj_info.主页面__活动弹窗_默认__关闭按钮)


@count_exec_time
def 前往人间(timeout=60):
    timestamp_start = get_timestamp_unix()
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        time_spent = int(get_timestamp_unix()) - int(timestamp_start)
        if time_spent > timeout:
            break

        res = click_by_image(obj_info.主页面__阵营战地图__地图按钮)
        if res:
            sleep(1)
            res2 = is_exsit(obj_info.主页面__地图弹窗_人间__天墉城文案)
            if res2:
                click_by_image(obj_info.主页面__地图弹窗_人间__关闭按钮)
                break
            click_by_image(obj_info.主页面__地图弹窗_地府__回人界按钮)

        click_by_image(obj_info.主页面__地图弹窗_人间__关闭按钮)


@count_exec_time
def 前往人间2(timeout=60):
    前往人间()


def main():
    account_list = [
        "木系账号",
        "水系账号",
        "火系账号",
        # "男火账号",
    ]
    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)
        # break  # 暂时不执行

        # 悬赏任务
        logger.info("执行领取悬赏任务")

        date_today_str = get_timestamp()[:8]

        # 获取配置文件信息
        config_file_name = "daily_task.json"
        config_file_path = os.path.join(
            project_paths.project_tmp_path, config_file_name
        )
        try:
            config_json = json_.json_file_to_dict(config_file_path)
        except:
            config_json = {}
            json_.dict_to_json_file(config_json, config_file_path)

        try:
            config_json[date_today_str]
        except:
            config_json = {date_today_str: {}}

        task_list = ["领取悬赏任务"]

        timestamp_hour = get_timestamp()[8:12]
        if int(timestamp_hour) > 2000 or int(timestamp_hour) < 500:
            task_list = []

        # 所有账号任务完成则终止程序
        is_finished_all = True
        # finished_account_list = []

        for 账号类型 in account_list:
            try:
                账号任务情况 = config_json[date_today_str][账号类型]
            except:
                config_json[date_today_str].update({账号类型: []})
                账号任务情况 = config_json[date_today_str][账号类型]
            for task in task_list:
                if task not in 账号任务情况:
                    is_finished_all = False

        if is_finished_all:
            logger.info("所有账号，领取悬赏任务已完成")
            break

        # 账号类型 = 获取当前账号()
        # logger.info(f"账号类型:{账号类型}")
        # if 账号类型 in finished_account_list:
        #     continue
        # if 账号类型 not in account_list:
        #     continue
        # 账号类型 = 切换账号()

        账号类型 = 切换账号()
        logger.info(f"账号类型:{账号类型}")
        # if 账号类型 in finished_account_list:
        #     continue
        if 账号类型 not in account_list:
            continue

        # 参战宠物1()
        # 参战宠物2()
        # 打开双倍()
        # 打开驱魔香()
        离开队伍()

        try:
            账号任务情况 = config_json[date_today_str][账号类型]
        except:
            config_json[date_today_str].update({账号类型: []})
            账号任务情况 = config_json[date_today_str][账号类型]

        for task in task_list:
            if task not in 账号任务情况:
                logger.info(f"当前账号：{账号类型}，当前执行任务：{task}")
                res = eval(f"{task}()")
                账号任务情况.append(task)

            json_.dict_to_json_file(config_json, config_file_path)

    while True:
        click_by_image(obj_info.主页面__邀请组队弹窗__取消按钮)

        date_today_str = get_timestamp()[:8]

        # 日常任务
        logger.info("执行日常任务")

        # 获取配置文件信息
        config_file_name = "daily_task.json"
        config_file_path = os.path.join(
            project_paths.project_tmp_path, config_file_name
        )
        try:
            config_json = json_.json_file_to_dict(config_file_path)
        except:
            config_json = {}
            json_.dict_to_json_file(config_json, config_file_path)
        try:
            config_json[date_today_str]
        except:
            config_json = {date_today_str: {}}

        timestamp_hour = get_timestamp()[8:12]
        if int(timestamp_hour) > 2000 or int(timestamp_hour) < 500:
            task_list = [
                "离开队伍2",
                "副本领取奖励",
                "关闭双倍",
                "关闭刷道道具",
                "领取刷道积分奖励",
                "全局刷道积分奖励",
                "使用刷道领和卷轴",
                "技能防御",
                "宠物休息",
                "修法任务",
                "法宝补灵气",
                "月道福运2",
                "神秘大礼2",
                "天工府领取2",
                "天工府造物2",
                # "洛书试炼场2",
                # "淬魂阁2",
                "聚神楼2",
                "洛书升级2",
                "神将装备穿戴2",
                # "引魂入殿",
                # "前往人间2",
                # "补充储备",
                # "补充忠诚",
                # "补充寿命",
                "阵营战地图进入",
                "阵营战任务",
                "阵营战地图返回",
            ]

        else:
            task_list = [
                "参战宠物1",
                "参战宠物2",
                "打开双倍",
                "技能攻击",
                "打开驱魔香",
                "离开队伍",
                "师门任务",
                "帮派任务",
                "竞技场",
                "助人为乐",
                "帮派日常挑战",
                "通天塔",
                "斗宠大会",
                "名人膜拜",
                "魔龙之祸",
                "悬赏任务",
                "活跃奖励",
                "使用刷道领和卷轴2",
                "每日签到",
                "神秘大礼",
                "会员元宝",
                # "升级福利",
                "天工府领取",
                "天工府造物",
                # "关闭高托自动匹配",
                "使用药品",
                "军备库分解",
                "洛书试炼场",
                "聚神楼",
                "洛书升级",
                "神将装备穿戴",
                "淬魂阁",
                "月道福运",
                # "阵营战地图进入",
                # "阵营战任务",
                # "阵营战地图返回",
                # "武魂升级",
                "引魂入殿",
                "前往人间",
            ]

        # 所有账号任务完成则终止程序
        is_finished_all = True
        finished_account_list = []

        for 账号类型 in account_list:
            try:
                账号任务情况 = config_json[date_today_str][账号类型]
            except:
                config_json[date_today_str].update({账号类型: []})
                账号任务情况 = config_json[date_today_str][账号类型]
            for task in task_list:
                if task not in 账号任务情况:
                    is_finished_all = False
                if not is_finished_all:
                    break

        if is_finished_all:
            logger.info("所有账号，日常任务已完成")
            break

        # 账号类型 = 获取当前账号()
        账号类型 = 切换账号()
        if 账号类型 in finished_account_list:
            continue
        if 账号类型 not in account_list:
            continue

        global is_over_100
        # is_over_100 = 是否等级大于100()
        is_over_100 = True

        try:
            账号任务情况 = config_json[date_today_str][账号类型]
        except:
            config_json[date_today_str].update({账号类型: []})
            账号任务情况 = config_json[date_today_str][账号类型]

        for task in task_list:
            if task not in 账号任务情况:
                logger.info(f"当前账号：{账号类型}，当前执行任务：{task}")
                eval(f"{task}()")
                账号任务情况.append(task)

            json_.dict_to_json_file(config_json, config_file_path)


if __name__ == "__main__":
    """
    "领取悬赏任务","悬赏任务"

    """
    os.environ["screenshot_path"] = ""  # 启动时清空一下环境变量
    get_adb_devices_ready()
    global is_over_100
    is_over_100 = True
    main()

    # 离开队伍()

    # if is_exsit(obj_info.主页面__人物信息弹窗_水系账号__编号区域):
    #     res = "水系账号"
    #     logger.info(f"当前账号类型:{res}")
    # if is_exsit(obj_info.主页面__人物信息弹窗_木系账号__编号区域):
    #     res = "木系账号"
    #     logger.info(f"当前账号类型:{res}")
    # if is_exsit(obj_info.主页面__人物信息弹窗_火系账号__编号区域):
    #     res = "火系账号"
    #     logger.info(f"当前账号类型:{res}")

    # 悬赏任务()
    # 阵营战地图进入()
    # 阵营战任务()
    # 阵营战地图返回()
    # 前往人间()
    # 阵营战地图进入()
    # 阵营战地图返回()
    # 阵营战任务()
    # 武魂升级()
    # 使用刷道领和卷轴()
    # 关闭高托自动匹配()
    # 切换账号()
    # 魔龙之祸()
    # 斗宠大会()
    # 会员元宝()
    # 领取刷道积分奖励()
    # 使用刷道领和卷轴()
    # 活跃奖励()
    # 每日签到()
    # 天工府领取()
    # 天工府造物()
    # 洛书试炼场()
    # 造化之池()
    # 关闭刷道道具()
    # 名人膜拜()
    # 使用刷道领和卷轴()
    # 军备库分解()
    # 神将装备穿戴()
    # 技能防御()
    # 宠物休息()
    # 法宝补灵气()
    # 洛书升级()
    # 技能攻击()
    # 淬魂阁()
    # 聚神楼()
    # 修法任务()
    # 使用药品()
    # 升级福利()
    # 离开队伍()
    # 技能防御()
    # 聚神楼()
